package org.zuel.controller;

import org.zuel.entity.Record;
import org.zuel.service.IRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.zuel.web.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;

/**
 *  控制器
 *
 * @author ikun
 */
@Api(tags = "管理")
@RestController
@RequestMapping("")
public class RecordController{

    private IRecordService recordService;

    @Autowired
    public RecordController(IRecordService recordService){
        this.recordService = recordService;
    }

    @ApiOperation("查询列表")
    @GetMapping("/record/list")
    public Object list(SelectRecord selectRecord) {
        return recordService.list(selectRecord);
    }

    @ApiOperation("查询单个")
    @GetMapping("/record/read/{id}")
    public JsonResult read(@PathVariable("id") Integer id) {
        return recordService.read(id);
    }

    @ApiOperation("添加")
    @PostMapping("/record/add")
    public JsonResult add(@RequestBody Record model) {
        return recordService.add(model);
    }

    @ApiOperation("修改")
    @PostMapping("/record/update")
    public JsonResult update(@RequestBody Record model) {
    return recordService.update(model);
    }

    @ApiOperation("删除")
    @GetMapping("/record/delete/{ids}")
    public JsonResult delete(@PathVariable("ids") Integer[] ids) {
        return recordService.delete(ids);
    }
    @ApiOperation("个人查询单个")
    @GetMapping("/record/readPersonally")
    public JsonResult read(@RequestBody SelectRecord selectRecord) {
        return recordService.readPersonally(selectRecord);
    }
}